Imports System.Windows.Controls
Imports System.Windows.Input
Imports System.Windows


Partial Public Class NumberZone
    Inherits DashboardZone

    Dim _Visual As New TextBlock()
    Dim _ValueProperty As DashboardZoneProperty
    Dim _TextFormatProperty As DashboardZoneProperty

    Sub New()

        Me._Visual.Text = "0%"
        Me._Visual.HorizontalAlignment = HorizontalAlignment.Center
        Me._Visual.VerticalAlignment = VerticalAlignment.Center

        Me._ValueProperty = New DashboardZoneProperty(Me, "Value", GetType(Double))
        Me.Properties.Add(_ValueProperty)
        Me._TextFormatProperty = New DashboardZoneProperty(Me, "TextFormat", GetType(String))
        Me._TextFormatProperty.EditorTemplate = "StringFormatCellEditingTemplate"
        Me.Properties.Add(_TextFormatProperty)
        Me.Properties.Add(New DashboardZoneProperty(Me, "FontFamily"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "FontStyle"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "FontWeight"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "FontStretch"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "FontSize"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "Foreground"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "Background"))
        'Me.Properties.Add(New DashboardZoneProperty(Me, "TextDecorations"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "Padding"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "TextAlignment"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "TextTrimming"))
        Me.Properties.Add(New DashboardZoneProperty(Me, "TextWrapping"))

    End Sub

    Public Overrides ReadOnly Property Visual As UIElement
        Get
            Return _Visual
        End Get
    End Property


    Protected Friend Overrides Sub OnValueChanged(ByVal [Property] As DashboardZoneProperty)
        Try
            If [Property] Is _ValueProperty Or [Property] Is _TextFormatProperty Then
                Me._Visual.Text = String.Format(CStr(Me._TextFormatProperty.Value), CDbl(Me._ValueProperty.Value))
            End If
        Catch ex As Exception

        End Try
    End Sub


    Protected Friend Overrides Sub OnDeserializeVisual(ByVal visual As System.Windows.UIElement)
        MyBase.OnDeserializeVisual(visual)
        Me._Visual = visual
    End Sub
End Class
